/*
 * @Author: wuqingchun
 * @Date: 2024-09-23 14:01:39
 * @Description: 封装
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-09-23 14:29:21
 */
#ifndef __CHAT_REDIS_H__
#define __CHAT_REDIS_H__


#include "../../deps/hiredis/hiredis.h"

class CChatRedis
{
public:
    CChatRedis(const char* pcHost="127.0.0.1", uint16_t usPort=6379);

    /**
     * @brief 向redis指定通道发布消息
     * 
     * @param iChannel  通道（监听的用户id）
     * @param pcMessage 消息
     * @return true 
     * @return false 
     */
    bool PublishMessage(int iChannel, const char* pcMessage);

    /**
     * @brief 订阅redis指定通道消息
     * 
     * @param iChannel 
     */
    void SubscribeMessage(int iChannel);

    /**
     * @brief 取消消息订阅
     * 
     * @param iChannel 
     */
    void UnSubscribeMessage(int iChannel);

    
private:
    redisContext* m_pstRedisCtx = nullptr;
};

#endif //__CHAT_REDIS_H__